<template>
  <div :class="`bn-head ${headClass}`">
    <div class="bn-logo">
      <div class="img">
        <img src="@/assets/images/jix/logo.png" width="40" height="40" style="margin-left: 16px;margin-right: 12px;"/>
      </div>
      <div class="img">
        <img src="@/assets/images/jix/logotitle.png" width="133" height="40" />
      </div>
    </div>
    <div :class="`bn-nav ${currentNavClass}`">
      <div :class="`item  ${activeIndex==index?'activeItem':''} `" v-for="(item,index) in menuList" :key="item.id" @click="exchangeNav(index)">
        <img v-show="currentNavClass == 'current-' + (item.path && item.path.split('/')[1])" style="margin-right:8px;z-index:1;" :src="`static/images/menu/current-${item.path && item.path.split('/')[1]}.png`"/>
        <img v-show="currentNavClass != 'current-' + (item.path && item.path.split('/')[1])" style="margin-right:8px;z-index:1;" :src="`static/images/menu/${item.path && item.path.split('/')[1]}.png`"/>
        <span style="z-index:1">{{item.name}}</span>
      </div>
      <!-- <div class="item monitor" @click="exchangeNav('monitor')">运行监控</div>
      <div class="item vehicleManage" @click="exchangeNav('vehicleManage')">车辆管理</div>
      <div class="item alarmRules" @click="exchangeNav('alarmRules')">规则管理</div>
      <div class="item statisticAnalyse" @click="exchangeNav('statisticAnalyse')">统计分析</div>
      <div class="item system" @click="exchangeNav('system')">系统管理</div> -->
    </div>
    <div class="bn-opt">
      <!-- <div class="user">
        {{real_name}}
      </div> -->
      <div class="bell-message" >
        <div class="message" >
          <span class="num">{{ totalNoticeNum }}</span>
        </div>
      </div>
      <el-popover placement="bottom" width="200" trigger="click">
        <div class="changeUser">
          <div class="item" @click="handleLogOut">退出登录</div>
        </div>
        <!-- <el-button slot="reference">click 激活</el-button> -->
        <div class="user" slot="reference">{{ real_name }}</div>
        <!-- <div class="user" slot="reference">测试名</div> -->
      </el-popover>
    </div>
   
  </div>
</template>

<script>
import { logout } from '@/api/account'
import Cookie from 'js-cookie'
export default {
  data() {
    return {
      activeIndex:0,
      currentNavClass: 'current-monitor',
      real_name: '',
      isLogin: true,
      centerDialogVisible: false,
      headClass: 'headClassHome',
      policeDate: '',
      warningMsgData: {},
      testWarningIndex: 0,
      totalNoticeNum:0
      
    }
  },
  mounted() {
   
  },
  props:['menuList',],

  computed: {
    getMenu() {
      return this.$store.state.permission.all_menu_list
    },
  },
  methods: {
    
    
    handleLogOut() {
      logout()
        .then((res) => {
          // localStorage.removeItem('checkedAreaKeyes')
          localStorage.clear()
          Cookie.remove('token')
          location.href = '/'
        })
        .catch((err) => {
          console.log(err, 'err')
          // localStorage.clear()
          // Cookie.remove('token')
          // location.href = '/'
        })
    },
    exchangeNav(index) {
      this.$emit('changeKey',index)
      this.activeIndex = index
      
      // if (param.path === '/monitor') {
      //   this.$router.push(param.path)
      // } else if (param.children[0].children[0].path) {
      //   this.$router.push(param.children[0].children[0].path)
      // }
    }
    
  },
  watch: {
  }
}
</script>
<style lang="less" scoped>
// @import '../../../assets/css/variable.scss';
// $nav-height: 60px;

/* 选中样式 */
@mixin current-style {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 9px;
  width: 100px;
  height: 2px;
  background: #FFCB4D;
}



.changeUser {
  background-color: #fff;
  border: 1px solid #ccc;
  z-index: 600;
  border-radius: 8px;
  padding: 10px;

  .item {
    height: 40px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
  }

  .changePass {
    border-bottom: 1px solid #ccc;
  }
}

.bn-head {
  width: 100%;
  height: 70px;
  box-shadow: 3px 3px 6px 0px #000000, 1px 1px 4px 0px #000000, 0px -2px 2px 0px rgba(253, 253, 253, 0.12), 0px 1px 2px 0px rgba(253, 253, 253, 0.24);
  display: flex;
  justify-content: space-between;
  background-image: url('@/assets/images/jix/titleBg.png');
  // background-image: url('../../../../static/images/homeBackground1.png');
  background-repeat: no-repeat;
  background-size: 100% 100%;

  .bn-logo {
    display: flex;
    flex-direction: row;
    line-height: 60px;

    .img {
      display: flex;
      align-items: center;

      &:nth-child(2) {
        margin-left: 10px;
      }
    }
  }

  .bn-nav {
    display: flex;
    align-items: center;

    .item {
      font-size: 14px;
      font-family: Microsoft YaHei;
      color: #ffffff;
      background: linear-gradient(0deg, rgba(146, 150, 155, 0.6) 0%, rgba(255, 255, 255, 0.6) 39.990234375%);
      -webkit-background-clip: text;
      // -webkit-text-fill-color: transparent;
      display: flex;
      align-items: center;
      flex-direction: column;
      justify-content: center;
      position: relative;
      cursor: pointer;
      width: 88px;
      height: 56px;
      margin-left: 16px;
      
      border-radius: 8px;
      span{
        margin-top: 4px;
        font-size: 14px;
        line-height: 22px;
      }
    }
    /* 鼠标悬浮 */
    .item:hover::after {
      content: ' ';
      position: absolute;
      left: -3px;
      top: 0px;
      width: 88px;
      height: 56px;
      background: #2F7DF1;
      border-radius: 5px;
    }
    /* 鼠标按下 */
   .item:active::after {
      content: ' ';
      position: absolute;
      left: -3px;
      top: 0px;
      width: 88px;
      height: 56px;
      background: #2F7DF1;
      border-radius: 5px;
    }

  }
  .activeItem {
      font-weight: bold !important;
      background: #2F7DF1 !important;

      &::after {
        @include current-style();
      }
    }
  .current-monitor {
    .item {
      font-weight: 400;
      
    }
    /* 标题选中样式 */
    .monitor {
      font-weight: bold;
      color: #FFFFFF;

      &::after {
        @include current-style();
      }
    }
  }
 
  .current-vehicleManage {
    .item {
      font-weight: 400;
    }

    .vehicleManage {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-alarmRules {
    .item {
      font-weight: 400;
    }

    .alarmRules {
      color: #FFCB4D;
      font-weight: bold;

      &::after {
        @include current-style();
      }
    }
  }

  .current-statisticAnalyse {
    .item {
      font-weight: 400;
    }

    .statisticAnalyse {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-inspectionManage {
    .item {
      font-weight: 400;
    }

    .inspectionManage {
      font-weight: bold;
      color: #FFCB4D;
      &::after {
        @include current-style();
      }
    }
  }

  .current-system {
    .item {
      font-weight: 400;
      display: flex;
      flex-direction: column;
    }

    .system {
      color: #FFCB4D;
      font-weight: bold;
      &::after {
        @include current-style();
      }
    }
  }

  .bn-opt {
    display: flex;
    align-items: center;

    .user {
      display: flex;
      width: auto;
      height: 20px;
      background-image: url('@/assets/images/header/user.png');
      background-repeat: no-repeat;
      margin-left: 27px;
      margin-right: 30px;
      color: #fbfbfc;
      padding: 0 0 0 30px;
      cursor: pointer;
      font-size: 16px;
      // width: 20px;
      // overflow: hidden;
      // white-space: nowrap;
      // text-overflow: ellipsis;
    }
  }

  .dialog {
    position: absolute;
    top: 0;
    // height: 400px;
  }
}

.headClass {
 background-color: white;
}
.headClassHome {
//  background-color: black;
 background-image: url('@/assets/images/jix/titleBg.png');
 background-repeat: no-repeat;
 background-size: 100% 100%;
}
/* 消息小铃铛 */
.bell-message {
  // position: absolute;
  // right: 135px;
  // right: 335px;
  // top: -40px;
  z-index: 100;

  .message {
    display: flex;
    width: 20px;
    height: 20px;
    background-image: url('@/assets/images/header/message.png');
    position: relative;
    cursor: pointer;

    .num {
      position: absolute;
      padding: 0px 3px;
      min-width: 15px;
      height: 15px;
      border-radius: 15px;
      text-align: center;
      line-height: 15px;
      background: #ff334c;
      color: #fff;
      font-size: 14px;
      top: -7px;
      left: 7px;
    }
  }
}

</style>
